package org.yhx.learning.verticle;/*
 * Copyright (C), 2024, bigmoon
 * FileName:
 * Author:   bigmoon
 * Date:     2024/9/2 18:15
 * Description: //模块目的、功能描述
 * History: //修改记录
 * &lt;author&gt;      &lt;time&gt;      &lt;version&gt;    &lt;desc&gt;
 * 修改人姓名             修改时间            版本号                  描述
 */

import io.vertx.core.AbstractVerticle;
import io.vertx.core.Vertx;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class HellVerticle extends AbstractVerticle {

    private static final Logger LOGGER = LoggerFactory.getLogger(HellVerticle.class);


    @Override
    public void start() throws Exception {
        super.start();
        vertx.setPeriodic(5000L,it-> {
            try {
                Thread.sleep(2100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            LOGGER.info("log periodic val="+it);

        });
        vertx.createHttpServer().requestHandler(req->{
            System.out.println("http server listen:"+req.body());
            req.response().end("Hello!");
        }).listen(8080);
    }

    public static void main(String[] args) {

        Vertx vertx = Vertx.vertx();
        vertx.deployVerticle(new HellVerticle());
    }
}
